package cn.net.susan.controller.web;

import cn.net.susan.annotation.NoLogin;
import cn.net.susan.entity.ResponsePageEntity;
import cn.net.susan.entity.mall.ProductConditionEntity;
import cn.net.susan.entity.mall.ProductEntity;
import cn.net.susan.service.mall.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * web端商品controller
 *
 * @author 苏三，该项目是知识星球：java突击队 的内部项目
 * @date 2024/5/15 上午10:40
 */
@Api(tags = "web商品操作", description = "web商品操作")
@RestController
@RequestMapping("/v1/web/product")
@Validated
public class WebProductController {

    @Autowired
    private ProductService productService;

    /**
     * 根据条件搜索商品列表
     *
     * @param productConditionEntity 条件
     * @return 商品列表
     */
    @NoLogin
    @ApiOperation(notes = "根据条件搜索商品列表", value = "根据条件搜索商品列表")
    @PostMapping("/search")
    public ResponsePageEntity<ProductEntity> search(@RequestBody ProductConditionEntity productConditionEntity) {
        return productService.searchFromES(productConditionEntity);
    }
}
